package com.sanrenzu.chunbo.ui.vertical.gengduo;

import android.os.Handler;
import android.os.Looper;

import com.sanrenzu.chunbo.bean.zxb.ShuiGuoBean;
import com.sanrenzu.chunbo.bean.zxb.ShuiGuoChildBean;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by My on 2016/9/1.
 */
public class GengDuoPersenter implements GengDuoContract.Persenter{

    private GengDuoContract.View view;
    private GengDuoContract.Modle modle;

    public GengDuoPersenter(GengDuoContract.View view){
        this.view = view;
        modle= new GengDuoModle();
    }
    @Override
    public void onGerVerticalShuiGuo() {
        modle.onGetVerticalShuiGuoBean(new Callback<ShuiGuoBean>() {
            @Override
            public void onResponse(Call<ShuiGuoBean> call, Response<ShuiGuoBean> response) {
                ShuiGuoBean bean = response.body();
                final List<ShuiGuoChildBean> benas = bean.getBigClassList();
                Handler handler = new Handler(Looper.getMainLooper());
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.onGetVerticalShuiGuoChildBean(benas);
                    }
                });
            }
            @Override
            public void onFailure(Call<ShuiGuoBean> call, Throwable t) {
                t.printStackTrace();
            }
        });
    }
}
